const Stores = defineStore('vue-shop',() => {
    // 定义登录信息状态
    const business = ref({});

    function $ResetBusiness()
    {
        business.value = {};
    }

    return {
        business,
        $ResetBusiness
    }
},{
    persist: {
        key:'vue-shop',// 存储名称
        storage:localStorage,// 存储方式 sessionStorage || localStorage
    },
})


export default {
    // 在main.js use一下就自动执行install
    install(app)
    {
        // 初始化
        const stores = Stores();
        
        // 抽离ref对象
        const { business } = storeToRefs(stores);

        // 定义全局属性
        app.config.globalProperties.$business = business;
        app.config.globalProperties.$stores = stores;
        app.config.globalProperties.$ResetBusiness = stores.$ResetBusiness;
    }
}